package mipushdemo.xiaomi.com.diyitonghang.presenter.impl.zixunimpl;

import mipushdemo.xiaomi.com.diyitonghang.data.bean.HomeDataBean;
import mipushdemo.xiaomi.com.diyitonghang.model.imodel.zixunmodel.IDataModel;
import mipushdemo.xiaomi.com.diyitonghang.model.impl.zixunimpl.DataModelImpl;
import mipushdemo.xiaomi.com.diyitonghang.presenter.contract.homecontract.IDataContract;

public class DataPresenterImpl implements IDataContract.IDataPresenter {
    IDataContract.IDataView iDataView;
    private final IDataModel dataModel;

    public DataPresenterImpl(IDataContract.IDataView iDataView) {
        this.iDataView = iDataView;
        iDataView.setPresenter(this);
        dataModel = new DataModelImpl();
    }

    @Override
    public void login(String channelId, String userId) {
        iDataView.loading();
        dataModel.responseData(channelId,userId,new IDataModel.SetOnDataChangedListener() {
            @Override
            public void setOnData(HomeDataBean homeDataBean) {
                iDataView.showData(homeDataBean);
                iDataView.completed();
            }
        });
    }
}
